package com.lx.controller;

import com.lx.vo.Node;
import com.lx.service.CategoryService;
import com.lx.vo.CategoryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("category")
public class CategoryController {
    @Autowired
    private CategoryService categoryService;

    @GetMapping("/categories")
    public List<CategoryVo> selectCategory(){
        List<CategoryVo> categoryVos = categoryService.selectCategory();
        return categoryVos;
    }

    //动态树形组件
    @GetMapping("/nodes")
    public List<Node> showCategoryTree(){
        List<Node> nodes = categoryService.showNode();
        return nodes;
    }
}
